if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].GetPIApproval') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].GetPIApproval
GO

/************************************************************************************************
* Name:		GetPIApproval                                                          
* Purpose:	This stored procedure is used to see whether PI has signed off on the Workflow
*		
* PARAMETERS  
*	Name			Description
* -------------------------	-----------------------------
* @ExecutionId			Workflow Execution id 
* -------------------------------------------------------
* If it is Approved then the count will be more than 0 otherwise it will be 0.
************************************************************************************************
*Call: GetPIApproval 2142
* 
************************************************************************************************/
create procedure [dbo].[GetPIApproval]
(
	@ExecutionId int	
)
as
begin
set nocount on
	
	
	select count(Id) as 'Result'
	from swexecutionDetails 
	where executionid = @ExecutionId 
		and ActionName like '%PISignOff%' 
		and Output = 'Approved' 


set nocount off
END

go


